﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace T5._4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string gamein = "新游戏\n";
            gamein += "名称" + textBox1.Text + "\n";
            gamein += "类别" + checkBox1.Text + "\n";
            string state = "";
            if (radioButton1.Checked)
            {
                state = radioButton1.Text;
            }
            else if (radioButton2.Checked)
            {
                state = radioButton2.Text;
            }
            else
            {
                state = radioButton3.Text;
            }
            string tags = "";
            if (checkBox1.Checked)
            {
                tags += checkBox1.Text + ",";
            }
            if (checkBox2.Checked)
            {
                tags += checkBox2.Text + ",";
            }
            if (checkBox3.Checked)
            {
                tags += checkBox3.Text + ",";
            }
            if (checkBox4.Checked)
            {
                tags += checkBox4.Text + ",";
            }
            if (checkBox5.Checked)
            {
                tags += checkBox5.Text + ",";
                gamein += "特色" + tags + "\n";
                MessageBox.Show(gamein);
            }

            SqlDataReader reader = null;
            string Addgame = null;          
                try
                {
                    string sql = string.Format("insert into Task(Addgame) values '{0}'", textBox1.Text);
                    reader = sqlCommom.Select(sql);
                    while (reader.Read())
                    {
                        Addgame = reader["Addgame"].ToString();
                       
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("不明原因报错，请找管理员\n" + ex.Message);
                }
                if (Addgame == textBox1.Text)
                {
                    MessageBox.Show("添加成功");
                }             
            }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult result;
            result = MessageBox.Show("是否取消","输入提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
            if (result == DialogResult.OK)
            {
                MessageBox.Show("已取消");
            }
            else
            {
                MessageBox.Show("重新选择");
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
          
        }
    }
}
